﻿using System;
using System.Collections.Generic;
using System.Data.Common;

namespace Songhay.Data.GenericWeb.Procedures
{
    using Songhay.Data.GenericWeb.Properties;

    /// <summary>
    /// List procedures into the DBMS.
    /// </summary>
    public static partial class List
    {
        /// <summary>
        /// Lists all SegmentDocument data in the DBMS catalogue.
        /// </summary>
        /// <param name="commonConnection">The Common connection.</param>
        /// <returns>Returns an XML <see cref="System.String"/>.</returns>
        public static string SegmentDocuments(DbConnection commonConnection)
        {
            string s = Common.CommonScalar.GetString(commonConnection, Resources.ListSegmentDocuments, false);

            return s;
        }

        /// <summary>
        /// Lists all SegmentDocument data associated with the specified Document.
        /// </summary>
        /// <param name="commonConnection">The Common connection.</param>
        /// <param name="uniqueIdentifier">The unique identifier of the Document</param>
        /// <returns>Returns an XML <see cref="System.String"/>.</returns>
        public static string SegmentDocuments(DbConnection commonConnection, string uniqueIdentifier)
        {
            if(uniqueIdentifier == null) throw new ArgumentNullException("uniqueIdentifier", "The unique identifer is null.");

            Dictionary<string, object> paramSet = new Dictionary<string, object>(1);
            paramSet.Add("@DocumentId", uniqueIdentifier);
            string s = Common.CommonScalar.GetString(commonConnection, Resources.ListDocumentSegmentsByDocId, paramSet);
            //TODO: rename Resources.ListDocumentSegmentsByDocId consistently...

            return s;
        }
    }
}
